import com.google.common.base.Charsets;
import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

import java.io.*;

/***
 * @author hunter.d
 * @qq 657270652
 * @wx haitao-duan
 * @date 2020/9/1
 **/
public class BloomFilterDemo {
    public static void main(String[] args) throws Exception {
//        BloomFilter<CharSequence> bloomFilter = BloomFilter.create(Funnels.stringFunnel(Charsets.UTF_8), 1000000000);
//        bloomFilter.put("abc");
//        bloomFilter.put("bbc");
//        bloomFilter.put("ccc");
//        bloomFilter.put("ddd");
//        bloomFilter.put("eee");
//        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("d:/blm.obj"));
//        out.writeObject(bloomFilter);
//        out.close();

        System.out.println(System.currentTimeMillis());
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("d:/blm.obj"));
        BloomFilter<CharSequence> o = (BloomFilter<CharSequence>) in.readObject();
        System.out.println(System.currentTimeMillis());

        System.out.println(o.mightContain("eee"));
        System.out.println(System.currentTimeMillis());


    }

}
